import { SystemNormalEnum } from '@model/enum/SystemNormalEnum'
import { Message } from 'element-ui';
import { storageGet, storageSet } from '@src/util/storageV2'
import { CreateElement } from 'vue'
/**
 * @des 搜索的输入框的内容长度过长的相关处理
 */
export const getSystemNormalSearchInputForLength = (keyword: string, h?:CreateElement) => {
	try {
		// let userConfig = storageGet('searchlength-tips');
		// if(userConfig === 'close') return keyword
		let length: number = SystemNormalEnum.UsualSearchInputLength;
		if(keyword.length < length) return keyword
		let realKeyword: string = keyword.slice(0, length);
		// let toastCon = keyword.slice(length, length + 3);
		// let tipsChineseText = `"${toastCon}" 及其后面的字词均被忽略，因为我们的查询限制在${length}个字符以内`;
		// let noMoreChineseText = '不再提示'
		// let MessageObj = Message({
		// 	message: (
		// 		h('div', { style: { paddingRight: '25px', lineHeight:1.2 } }, [
		// 			h('span', {}, tipsChineseText),
		// 			h('span', {
		// 				class:'color-primary',
		// 				style: {
		// 					marginLeft: '8px',
		// 					cursor: 'pointer',
		// 				},
		// 				on: {
		// 					click: () => {
		// 						MessageObj && MessageObj.close();
		// 						storageSet('searchlength-tips', 'close');
		// 					}
		// 				}
		// 			}, noMoreChineseText)
		// 		])
		// 	),
		// 	showClose: true,
		// 	duration: 0
		// })
		return realKeyword
	} catch (error) {
		console.warn(error, 'error try catch getSystemNormalSearchInputForLength');
	}
	return keyword
}

/**
 * @des 获取项目内涉及后端搜索的输入框的内容长度
 */
export const getNormalSearchKeywordLength = ()=>{
	return SystemNormalEnum.UsualSearchInputLength
}